package snippet;

import java.util.Arrays;

public class T922 {
	public static void main(String[] args) {
		int[] a = { 4, 2, 5, 7 };
		System.out.println(Arrays.toString(new T922().sortArrayByParityII(a)));
	}

	public int[] sortArrayByParityII(int[] A) {
		int[] arr = new int[A.length];
		int a = 0, b = 1;
		for (int i = 0; i < A.length; i++) {
			if(A[i]%2==0) {
				arr[a]=A[i];
				a+=2;
			}else {
				arr[b]=A[i];
				b+=2;
			}
		}
		return arr;

	}
}
